<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreAdminPost extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username' => 'required|unique:admins',
            'password' => 'required|min:6|max:25'
        ];
    }

    public function messages()
    {
        return [
            'username.required' => '管理员名称不能为空',
            'username.unique' => '管理员名称已存在',
            'password.required' => '密码不能为空',
            'password.min' => '密码长度不能低于6位',
            'password.max' => '密码长度不能高于25位',
        ];
    }
}
